package damas2;


/*
 * Damas2AboutBox.java
 */

import java.awt.event.KeyEvent;


public class Novo_Jogo extends javax.swing.JDialog {
    private String jogador;

    public String getJogador() {
        return jogador;
    }

    public Novo_Jogo(java.awt.Frame parent) {
        super(parent);
        initComponents();
        lbl_Erro.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txt_OK = new javax.swing.JTextField();
        btn_OK = new javax.swing.JButton();
        lbl_Erro = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(Novo_Jogo.class);
        setTitle(resourceMap.getString("estatisticaBox.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setModal(true);
        setName("estatisticaBox"); // NOI18N
        setResizable(false);

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        txt_OK.setText(resourceMap.getString("txt_nome.text")); // NOI18N
        txt_OK.setName("txt_nome"); // NOI18N
        txt_OK.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txt_OKKeyPressed(evt);
            }
        });

        btn_OK.setText(resourceMap.getString("btn_OK.text")); // NOI18N
        btn_OK.setName("btn_OK"); // NOI18N
        btn_OK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btn_OKMouseClicked(evt);
            }
        });

        lbl_Erro.setForeground(resourceMap.getColor("lbl_Erro.foreground")); // NOI18N
        lbl_Erro.setText(resourceMap.getString("lbl_Erro.text")); // NOI18N
        lbl_Erro.setName("lbl_Erro"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_Erro)
                    .addComponent(btn_OK)
                    .addComponent(txt_OK, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txt_OK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_Erro)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addComponent(btn_OK)
                .addGap(30, 30, 30))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_OKMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_OKMouseClicked
        // TODO add your handling code here:
        if (txt_OK.getText().toString().equals("")){
              lbl_Erro.setVisible(true);
          }
          else{
             jogador=txt_OK.getText().toString();
             dispose();
          }
    }//GEN-LAST:event_btn_OKMouseClicked

    private void txt_OKKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_OKKeyPressed
        int tecla = evt.getKeyCode();
        if (tecla==KeyEvent.VK_ENTER) {
             if (txt_OK.getText().toString().equals("")){
              lbl_Erro.setVisible(true);
          }
          else{
             jogador=txt_OK.getText().toString();
             dispose();
          }
        }
    }//GEN-LAST:event_txt_OKKeyPressed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_OK;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lbl_Erro;
    private javax.swing.JTextField txt_OK;
    // End of variables declaration//GEN-END:variables


}
